# -*- coding: utf-8 -*-

from PIL import Image
from PIL import ImageFilter
import cv2                
import matplotlib.pyplot as plt

img_path = 'animals/cat/1.jpg'
img = Image.open(img_path)  
print(img.mode) 

if img.mode != 'RGB':
    img = img.convert("RGB") #读取图片的过程中如果遇到非'RGB'就转换格式
    
blurF = img.filter(ImageFilter.BLUR)
conF = img.filter(ImageFilter.CONTOUR)
edgeF = img.filter(ImageFilter.FIND_EDGES)

fig,axes = plt.subplots(2,2,figsize=(20, 20))
axes[0,0].imshow(img)
axes[0,1].imshow(blurF)
axes[1,0].imshow(conF)
axes[1,1].imshow(edgeF)

# https://zhuanlan.zhihu.com/p/43268790